package sources;


import pojo.Person;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

/**
 * @author Europa
 * @create 2020-05-06 21:46
 */
public class HashMapTest {

    public static void main(String[] args) {
        HashMapTest test = new HashMapTest();
        //test.hashmapTest1();
        test.hashmapTestPerson();

    }

    private void hashmapTest1() {
        HashMapDemo<String, Integer> map = new HashMapDemo<>(16);
        for (int i = 0; i < 16; i++) {
            String s = "" + i;
            map.put(s, i);
        }

        System.out.println("map = " + map);

    }

    private void hashmapTestPerson() {
        ArrayList<Person> list = new ArrayList<>();
        for (int i = 19968; i < 20096; i++) {
            char c = (char) i;
            String s = String.valueOf(c);
            Person person = new Person(s, i - 19968);
            list.add(person);
        }
        HashMapDemo<String, Person> map = new HashMapDemo<>();
        HashMap<String, Person> hashMap = new HashMap<>();
        //String[] strings = new String[128];
        for (int i = 0; i < list.size(); i++) {
            String s = "" + i;
            Person person = list.get(i);
            map.put(s, person);
            hashMap.put(s, person);
        }


        System.out.println("map     = " + map.toString());

        System.out.println("hashMap = " + hashMap.toString());
    }

    private void hashmapTest() {
        HashMapDemo<Character, Integer> map = new HashMapDemo<>();
        for (int i = 161; i < 512; i++) {
            char c = (char) i;
            int n = i - 161;
            map.put(c, n);
        }
        System.out.println("map.table = " + Arrays.toString(map.table));
        for (int i = 161; i < map.size(); i++) {
            char c = (char) i;
            int integer = map.get(c);
            System.out.println(c + "\t" + integer);
        }
    }

    private void test() {
        for (int i = 161; i < 131072; i++) {
            System.out.print((char) i);
            if ((i - 160) % 50 == 0) {
                System.out.println();
            }
        }
    }


}
